package com.syedu.day15.homework;

/**
 * description：字母线程
 * @author Administrator
 * @date 2022/4/2 14:02
 */
public class LetterThread implements Runnable {
    private Object lock;

    public LetterThread(Object lock) {
        this.lock = lock;
    }

    @Override
    public void run() {
        synchronized (lock) {
            for (char c = 'A'; c <= 'Z'; c++) {
                System.out.print(c);
                try {
                    lock.notifyAll();
                    if (c != 'Z') {
                        lock.wait();
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}